flat assembler
Message board for the users of flat assembler.
 Home   FAQ   Search   Register 
 Profile   Log in to check your private messages   Log in 
flat assembler > OS Construction > Bootable cdrom ISO9660/Joliet image code

Author
Thread Post new topic Reply to topic
mikegonta



Joined: 20 Nov 2005
Posts: 50
Location: Canada
Bootable cdrom ISO9660/Joliet image code
The following code will create a bootable cdrom image, just add your boot sector code to the end and burn to CD or run in Bochs. This is "no emulation", you can specify the load segment and the size of the binary to load.
Reference documents:
Volume and File Structure of CDROM for Information Interchange
“El Torito” Bootable CD-ROM Format Specification Version 1.0
Constructing a Bootable CD Version 0.5

Code:

macro msb_dw x { dw ((x and 0FF00hshr 8or ((x and 0FFhshl 8) }

macro lb_dw x {
  dw x
  msb_dw x }

macro msb_dd x {
  dd ((x and 0FF000000hshr 24or ((x and 0FF0000hshr 8or \
  ((x and 0FF00hshl 8or ((x and 0FFhshl 24) }

macro lb_dd x {
  dd x
  msb_dd x }

macro binary_date yearmonthdayhourminutesecondoffset {
  db year-1900monthdayhourminutesecondoffset }

macro text_date yearmonthdayhourminutesecondhundredthoffset {
  db yearmonthdayhourminutesecondhundredthoffset }

Bootable_CD:
Read_Me:
  db "This is an ISO9660/Joliet bootable cdrom image.",0Dh,0Ah
  db "Copyright 2005 MikeGonta.com",0Dh,0Ah
  db "May be freely used and distributed for personal use.",0Dh,0Ah
  .Read_Me:
  times 2048*9-($-Read_Medb 0

BootCat.Bin:
  .Validation_Entry:
    .Header_IDdb 1
    .Platform_IDdb 0
    dw 0
    .ID_Stringdb ""
      times 24 db 0
    .Checksum_Worddb 0AAh55h
    .Signature db 55h0AAh
  .Default_Entry:
    .Boot_Indicatordb 88h
    .Boot_Media_Typedb 0               ; no emulation
    .Load_Segmentdw 0                  ; the bios will load at 7C0:0 or 0:7c00
    .System_Typedb 0
    db 0
    .Virtual_Sector_Countdw 4          ; one CD sector
    .Load_RBAdd (Boot_Sector-Bootable_CD)/2048
  times 2048-($-BootCat.Bindb 0

Primary_Directory_Records:
  Primary_1:
    .sizedb 34
    .extended_attributedb 0
    .locationlb_dd ((Primary_Directory_Records-Bootable_CD)/2048)
    .data_lengthlb_dd 2048
    binary_date 2005110000
    .file_flagsdb 2
    .file_unit_sizedb 0
    .interleave_gap_sizedb 0
    .volume_sequence_numberlb_dw 0
    .length_of_file_identifierdb 1
    .file_identifierdb 0
  Primary_2:
    .sizedb 34
    .extended_attributedb 0
    .locationlb_dd ((Primary_Directory_Records-Bootable_CD)/2048)
    .data_lengthlb_dd 2048
    binary_date 2005110000
    .file_flagsdb 2
    .file_unit_sizedb 0
    .interleave_gap_sizedb 0
    .volume_sequence_numberlb_dw 0
    .length_of_file_identifierdb 1
    .file_identifierdb 1
  Primary_Readme:
    .sizedb .Primary_Readme-Primary_Readme
    .extended_attributedb 0
    .locationlb_dd ((Read_Me-Bootable_CD)/2048)
    .data_lengthlb_dd (Read_Me.Read_Me-Read_Me)
    binary_date 2005110000
    .file_flagsdb 0
    .file_unit_sizedb 0
    .interleave_gap_sizedb 0
    .volume_sequence_numberlb_dw 0
    .length_of_file_identifierdb .Primary_Readme-.file_identifier
    .file_identifierdb "README.TXT",59,49
    .Primary_Readme:
  times 2048-($-Primary_Directory_Recordsdb 0

Primary_Type_L_Path_Table:
  .sizedb 1
  .extended_attributedb 0
  .extent_locationdd ((Primary_Directory_Records-Bootable_CD)/2048)
  .parent_directorydw 1
  .directory_identifierdw 0
  times 2048-($-Primary_Type_L_Path_Tabledb 0

Primary_Type_M_Path_Table:
  .sizedb 1
  .extended_attributedb 0
  .extent_locationmsb_dd ((Primary_Directory_Records-Bootable_CD)/2048)
  .parent_directorymsb_dw 1
  .directory_identifiermsb_dw 0
  times 2048-($-Primary_Type_M_Path_Tabledb 0

Supplementary_Directory_Records:
  Supplementary_1:
    .sizedb 34
    .extended_attributedb 0
    .locationlb_dd ((Supplementary_Directory_Records-Bootable_CD)/2048)
    .data_lengthlb_dd 2048
    binary_date 2005110000
    .file_flagsdb 2
    .file_unit_sizedb 0
    .interleave_gap_sizedb 0
    .volume_sequence_numberlb_dw 0
    .length_of_file_identifierdb 1
    .file_identifierdb 0
  Supplementary_2:
    .sizedb 34
    .extended_attributedb 0
    .locationlb_dd ((Supplementary_Directory_Records-Bootable_CD)/2048)
    .data_lengthlb_dd 2048
    binary_date 2005110000
    .file_flagsdb 2
    .file_unit_sizedb 0
    .interleave_gap_sizedb 0
    .volume_sequence_numberlb_dw 0
    .length_of_file_identifierdb 1
    .file_identifierdb 1
  Supplementary_Readme:
    .sizedb .Supplementary_Readme-Supplementary_Readme
    .extended_attributedb 0
    .locationlb_dd ((Read_Me-Bootable_CD)/2048)
    .data_lengthlb_dd (Read_Me.Read_Me-Read_Me)
    binary_date 2005110000
    .file_flagsdb 0
    .file_unit_sizedb 0
    .interleave_gap_sizedb 0
    .volume_sequence_numberlb_dw 0
    .length_of_file_identifierdb .Supplementary_Readme-.file_identifier
    .file_identifier:
      db 0,"R",0,"e",0,"a",0,"d",0," ",0,"m",0,"e",0,".",0,"t",0,"x",0,"t"
      db 0,59,0,49
    .Supplementary_Readme:
  times 2048-($-Supplementary_Directory_Recordsdb 0

Supplementary_Type_L_Path_Table:
  .sizedb 1
  .extended_attributedb 0
  .extent_locationdd ((Supplementary_Directory_Records-Bootable_CD)/2048)
  .parent_directorydw 1
  .directory_identifierdw 0
  times 2048-($-Supplementary_Type_L_Path_Tabledb 0

Supplementary_Type_M_Path_Table:
  .sizedb 1
  .extended_attributedb 0
  .extent_locationmsb_dd ((Supplementary_Directory_Records-Bootable_CD)/2048)
  .parent_directorymsb_dw 1
  .directory_identifiermsb_dw 0
  times 2048-($-Supplementary_Type_M_Path_Tabledb 0

Primary_Volume_Descriptor:
  .Volume_Descriptor_Typedb 1
  .Standard_Identifierdb "CD001"
  .Volume_Descriptor_Versiondb 1
  .Volume_Flags db 0
  .System_Identifier:
    times 32-($-.System_Identifierdb " "
  .Volume_Identifierdb "BOOTABLE_CD"
    times 32-($-.Volume_Identifierdb " "
  times 8 db 0
  .Volume_Space_Sizelb_dd ((Boot_Sector-Bootable_CD)/2048)
  times 32 db 0
  .Volume_Set_Sizelb_dw 1
  .Volume_Sequence_Numberlb_dw 1
  .Logical_Block_Sizelb_dw 2048
  .Path_Table_Sizelb_dd 10
  .Type_L_Path_Tabledd ((Primary_Type_L_Path_Table-Bootable_CD)/2048)
  .Optional_Type_L_Path_Tabledd 0
  .Type_M_Path_Tablemsb_dd ((Primary_Type_M_Path_Table-Bootable_CD)/2048)
  .Optional_Type_M_Path_Tablemsb_dd 0
  .Root_Directory_Record:
    .sizedb 34
    .extended_attributedb 0
    .locationlb_dd ((Primary_Directory_Records-Bootable_CD)/2048)
    .data_lengthlb_dd 2048
    binary_date 2005110000
    .file_flagsdb 2
    .file_unit_sizedb 0
    .interleave_gap_sizedb 0
    .volume_sequence_numberlb_dw 0
    .length_of_file_identifierdb 1
    .file_identifierdb 0
  .Volume_Set_Identifier:
    times 128-($-.Volume_Set_Identifierdb " "
  .Publisher_Identifier:
    times 128-($-.Publisher_Identifierdb " "
  .Data_Preparer_Identifier:
    times 128-($-.Data_Preparer_Identifierdb " "
  .Application_Identifier:
    times 128-($-.Application_Identifierdb " "
  .Copyright_File_Identifier:
    times 37-($-.Copyright_File_Identifierdb " "
  .Abstract_File_Identifier:
    times 37-($-.Abstract_File_Identifierdb " "
  .Bibliographic_File_Identifier:
    times 37-($-.Bibliographic_File_Identifierdb " "
  Primary_Volume_Creation_Date_and_Time:
    text_date "2005""01""01""00""00""00""00"0
  Primary_Volume_Modification_Date_and_Time:
    text_date "2005""01""01""00""00""00""00"0
  .Volume_Expiration_Date_and_Time:
    times 17 db 0
  .Volume_Effective_Date_and_Time:
    times 17 db 0
  .File_Structure_Versiondb 1
  times 2048-($-Primary_Volume_Descriptordb 0

Boot_Record_Descriptor:
  .Volume_Descriptor_Typedb 0
  .Standard_Identifierdb "CD001"
  .Volume_Descriptor_Versiondb 1
  .Boot_System_Identifierdb "EL TORITO SPECIFICATION"
    times 64-($-.Boot_System_Identifierdb 0
  .Boot_Catalog_Sectordd (BootCat.Bin-Bootable_CD)/2048
  times 2048-($-Boot_Record_Descriptordb 0

Supplementary_Volume_Descriptor:
  .Volume_Descriptor_Typedb 2
  .Standard_Identifierdb "CD001"
  .Volume_Descriptor_Versiondb 1
  .Volume_Flags db 0
  .System_Identifier:
    times 32-($-.System_Identifierdb 0
  .Volume_Identifier:
    db 0,"B",0,"o",0,"o",0,"t",0,"a",0,"b",0,"l",0,"e",0," ",0,"C",0,"D"
    times 32-($-.Volume_Identifierdb 0
  times 8 db 0
  .Volume_Space_Sizelb_dd ((Boot_Sector-Bootable_CD)/2048)
  .Escape_Sequencedb 374769
    times 32-($-.Escape_Sequencedb 0
  .Volume_Set_Sizelb_dw 1
  .Volume_Sequence_Numberlb_dw 1
  .Logical_Block_Sizelb_dw 2048
  .Path_Table_Sizelb_dd 10
  .Type_L_Path_Tabledd ((Supplementary_Type_L_Path_Table-Bootable_CD)/2048)
  .Optional_Type_L_Path_Tabledd 0
  .Type_M_Path_Tablemsb_dd ((Supplementary_Type_M_Path_Table-Bootable_CD)/2048)
  .Optional_Type_M_Path_Tablemsb_dd 0
  .Root_Directory_Record:
    .sizedb 34
    .extended_attributedb 0
    .locationlb_dd ((Supplementary_Directory_Records-Bootable_CD)/2048)
    .data_lengthlb_dd 2048
    binary_date 2005110000
    .file_flagsdb 2
    .file_unit_sizedb 0
    .interleave_gap_sizedb 0
    .volume_sequence_numberlb_dw 0
    .length_of_file_identifierdb 1
    .file_identifierdb 0
  .Volume_Set_Identifier:
    times 128-($-.Volume_Set_Identifierdb 0
  .Publisher_Identifier:
    times 128-($-.Publisher_Identifierdb 0
  .Data_Preparer_Identifier:
    times 128-($-.Data_Preparer_Identifierdb 0
  .Application_Identifier:
    times 128-($-.Application_Identifierdb 0
  .Copyright_File_Identifier:
    times 37-($-.Copyright_File_Identifierdb 0
  .Abstract_File_Identifier:
    times 37-($-.Abstract_File_Identifierdb 0
  .Bibliographic_File_Identifier:
    times 37-($-.Bibliographic_File_Identifierdb 0
  Supplementary_Volume_Creation_Date_and_Time:
    text_date "2005""01""01""00""00""00""00"0
  Supplementary_Volume_Modification_Date_and_Time:
    text_date "2005""01""01""00""00""00""00"0
  .Volume_Expiration_Date_and_Time:
    times 17 db 0
  .Volume_Effective_Date_and_Time:
    times 17 db 0
  .File_Structure_Versiondb 1
  times 2048-($-Supplementary_Volume_Descriptordb 0

Terminator_Volume_Descriptor:
  .Volume_Descriptor_Typedb 255
  .Standard_Identifierdb "CD001"
  .Volume_Descriptor_Versiondb 1
  times 2048-($-Terminator_Volume_Descriptordb 0

Boot_Sector:
  org 7C00h



_________________
look and see - many look but few see

Image


Last edited by mikegonta on 06 Jan 2006, 11:07; edited 8 times in total
Post 20 Nov 2005, 22:22
View user's profile Send private message Reply with quote
mikegonta



Joined: 20 Nov 2005
Posts: 50
Location: Canada
----- Original Message -----
From: "andreyw"
Newsgroups: alt.os.development
Sent: Monday, November 21, 2005 11:51 AM
Subject: Re: Bootable cdrom ISO9660/Joliet image code


Quote:

I hate to be a malcontent, but aren't there tools that do this for you
already, given a floppy disc image (obviously this is the El Torito fd
emu versus "native'')?



"El Torito" is the standard by which the bios boots from the CD.

Of course, simply drag and drop your image into your favorite cd burning
software and create a disk image.

But ...

This is to simplify OS dev. First assemble the code. Then copy append your
boot sector code and run it in Bochs and shorten the development cycle. Also
if you study the code you will see that I have placed most of the records in
the first 16 CD sectors normally left blank and reserved for the system. I
even put the readme file in there. This is to make a small file.

_________________
look and see - many look but few see

Image


Last edited by mikegonta on 07 Dec 2005, 00:35; edited 1 time in total
Post 21 Nov 2005, 23:53
View user's profile Send private message Reply with quote
revolution



Joined: 24 Aug 2004
Posts: 2215
Location: In hiding
Thanks for the info mikegonta. Very useful.
Post 22 Nov 2005, 01:48
View user's profile Send private message Visit poster's website Reply with quote
mikegonta



Joined: 20 Nov 2005
Posts: 50
Location: Canada
----- Original Message -----
From: "Laurent D.A.M. Menten"
Newsgroups: alt.os.development
Sent: Wednesday, November 23, 2005
Subject: Re: Bootable cdrom ISO9660/Joliet image code


Quote:
andreyw wrote:

I hate to be a malcontent, but aren't there tools that do this for you already, given a floppy disc image (obviously this is the El Torito fd emu versus "native")?

You're so right, but everyone seems to ignore that...



You're so wrong, if you look at the code you will see that the image file created is customized to suit my purpose of simplicity and minimum size - the only programming tool that can do that is an assembler. In this case I am using Fasm - the Flat Assembler. http://board.flatassembler.net/

_________________
look and see - many look but few see

Image
Post 23 Nov 2005, 03:07
View user's profile Send private message Reply with quote
MarcoAlves



Joined: 09 Jun 2006
Posts: 30
mikegonta, your tool is VERY VERY NICE. Congratulations man.

But, I've just one question:

How I can put other files into the bootable image file? like a picture, a txt file, etc etc, i.e., the needed files to start my os setup, like windows xp cd setup.

I'm using VMWare. I had tested your tool with it and all works fine. My
bootloader was loaded by VMWare, after compiling my code with your
tool.

Best Regards,
Marco Alves.
Post 14 Jun 2006, 21:04
View user's profile Send private message Reply with quote
vid



Joined: 05 Sep 2003
Posts: 5445
Location: Slovakia
very nice, thanks.

should go to interesting threads/OSdev
Post 14 Jun 2006, 21:14
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
Dex4u



Joined: 08 Feb 2005
Posts: 1003
Location: UK
I can not see the point, how is it simpler that having a floppy or Hdd image and clicking on the "make bootable" in your burn software ?.
The above method does use emulation of floppy or hdd and emulation stops up on entering pmode.

But if you go back to realmode to use int 13h, emulation starts again, and it no slower than a pmode floppy or hdd driver, that why i have two floppy and hdd drivers, theres big advantages in using int 13h by going back and forth, eg: read/write USB pen drives, and being able to load from CD, under emulation.

NOTE: I am not ? the code, but rather the mefod, being simpler Wink

_________________
DexOS Batteries not included, Some assembly required.
Post 14 Jun 2006, 22:11
View user's profile Send private message Visit poster's website Reply with quote
MarcoAlves



Joined: 09 Jun 2006
Posts: 30

Dex4u wrote:
I can not see the point, how is it simpler that having a floppy or Hdd image and clicking on the "make bootable" in your burn software ?.
The above method does use emulation of floppy or hdd and emulation stops up on entering pmode.

But if you go back to realmode to use int 13h, emulation starts again, and it no slower than a pmode floppy or hdd driver, that why i have two floppy and hdd drivers, theres big advantages in using int 13h by going back and forth, eg: read/write USB pen drives, and being able to load from CD, under emulation.

NOTE: I am not ? the code, but rather the mefod, being simpler Wink



I'm noob. But, I think that this tool is useful for me because I've a notebook
and it doesn't has a floppy drive. If you have other suggestions and
how I can put the files into a image file and load them in VMWare, I will
appreciate.

Best Regards,
Marco Alves.
Post 19 Jun 2006, 13:06
View user's profile Send private message Reply with quote
Dex4u



Joined: 08 Feb 2005
Posts: 1003
Location: UK
First i want to make it clear that its a nice and usefull peace of code, i was just pointing that making a bootable cd is esaier by using burn software.
Now to answer you ?, although i have not used this mefod my self (as i have a floppy drive), from my understanding, you can with this tool (the free ver)
http://ourworld.compuserve.com/homepages/gvollant/download.htm
To inject files and directories into an existing disk image, that mean you just need to down load some floppy image and take out there file and inject yours.

Hope this helps.

_________________
DexOS Batteries not included, Some assembly required.
Post 19 Jun 2006, 14:36
View user's profile Send private message Visit poster's website Reply with quote
MarcoAlves



Joined: 09 Jun 2006
Posts: 30
I'd downloaded the software but it can't open the bin file generated with
the tool coded by mikegonta. Can you help-me?

Dex4u, a simple question: Suppose that I can put the files into the cd.
How I can read those files from my asm app? Is this like reading from
hd?

THX IN ADVANCE.

Best Regards,
Marco Alves.
Post 20 Jun 2006, 13:14
View user's profile Send private message Reply with quote
Dex4u



Joined: 08 Feb 2005
Posts: 1003
Location: UK
Heres the basic way it works, if you put a floppy image or hdd image on to a cd by clicking the make bootable option.
Up on booting, it emulates the floppy or hdd so you A: drive is the floppy image on the cd and your real floppy drive (if you have 1) is your b: drive, as long as your OS code stays in realmode this is how it will work, but if you go to pmode emulation stops or there is a int that can stop emulation in realmode.

So to load program from the floppy image on the cd you can go to unreal mode and load the floppy image into a ramdisk like menuet does or you can go back to realmode use int 13h and read a: drive (as soon as you go back emulation starts again, unless you have done the int to stop it.
If you want to put other stuff on the cd, other than whats in the images, you need to make a ATAPI driver.

If you want i have a ATAPI driver for my OS written in fasm you can look at, if you decide to write one.

NOTE: If for example your bootloader normally users the floppy to load your kernel in realmode using int 13h, this will work just the same from the floppy image on the cd.

_________________
DexOS Batteries not included, Some assembly required.
Post 20 Jun 2006, 15:49
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >

Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum


Powered by phpBB © 2001-2005 phpBB Group.

Main index   Download   Documentation   Examples   Message board
Copyright © 2004-2005, Tomasz Grysztar.